package com.ssy.lingxi.settle.accounts.model.constant;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 支付方式
 * @author 伍将
 * @date 2020/10/23
 * @version 2.0.0
 */
public enum PayWayEnum {

    ALL(0, "所有"),
    /**
     * 线上支付
     */
    ONLINE_PAYMENT(1, "线上支付"),
    /**
     * 线下转账线上确认
     */
    OFFLINE_PAYMENT(2, "线下转账线上确认"),
    /**
     * 授信
     */
    CREDIT_LINE_PAYMENT(3, "授信"),
    /**
     * 货到付款
     */
    CASH_ON_DELIVERY(4, "货到付款");

    private final Integer code;
    private final String message;

    PayWayEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getDeclaringClass(), this.getCode());
    }

    public static String getMessage(Integer code) {
        return Arrays.stream(PayWayEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL).getMessage();
    }
}
